package org.smr.ministore.micro.client;

import org.blade.utils.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.entities.GoodsPrice;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import feign.hystrix.FallbackFactory;


@Component
public class HystrixGoodsPriceClientFactory implements FallbackFactory<FeignGoodsPriceMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixGoodsPriceClientFactory.class);

    @Override
    public FeignGoodsPriceMicroServiceClient create(Throwable cause) {
    HystrixGoodsPriceClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new FeignGoodsPriceMicroServiceClient() {

            @Override
            public int batchSave(List<GoodsPrice> entities) {
                return 0;
                }

            @Override
            public int batchModify(List<GoodsPrice> entities) {
                return 0;
                }

            @Override
            public int save(GoodsPrice entity) {
            return 0;
            }

            @Override
            public int updateById(GoodsPrice id) {
            return 0;
            }

            @Override
            public GoodsPrice queryById(Long id) {
                GoodsPrice goodsPrice = new GoodsPrice();
                goodsPrice.setId(-1L);
                return goodsPrice;
            }

            @Override
            public int deleteById(Long id) {
            return 0;
            }

            @Override
            public Pager<GoodsPrice> paginate(GoodsPrice entity, Long pageSize, Long pageNum) {
                Pager<GoodsPrice> pager = new Pager<GoodsPrice>();
                    return pager;
            }

            @Override
            public List<Map<String, Object>> getGoodsPriceList(Map<String, Object> params, Long pageSize, Long pageNum) {
                return Collections.EMPTY_LIST;
            }

            @Override
            public GoodsPrice getGoodsPriceBy(Long organId, Long goodsId) {
                GoodsPrice goodsPrice = new GoodsPrice();
                goodsPrice.setId(-1L);
                return goodsPrice;
            }

        };//Return end
    }
}